const fs = require('fs')
const http = require('http')

http.createServer((req, res) => {
  req.setEncoding('utf8')
  // 大文件读取最好不要用readFile, 最好用流的方式替代fs.createReadStream()
  // fs.readFile('../glob/index.js', 'utf8', (err, data) => {
  //   if (err) throw err
  //   res.end(data)
  // })
  const read = fs.createReadStream('../glob/index.js')
  read.pipe(res)
}).listen(8090)

console.log('server is listening at http://localhost:8090/')
